﻿Type=Activity
Version=5.8
ModulesStructureVersion=1
B4A=true
@EndOfDesignText@
#Region  Activity Attributes 
	#FullScreen: False
	#IncludeTitle: True
#End Region

Sub Process_Globals
	'These global variables will be declared once when the application starts.
	'These variables can be accessed from all modules.

End Sub

Sub Globals
	'These global variables will be redeclared each time the activity is created.
	'These variables can only be accessed from this module.
	Private btngopay As Button
	Private lbladdress As Label
	Private lblcuxiaoquan As Label
	Private lblfudaobanname As Label
	Private lbljiesuankechengprice As Label
	Private lbljiesuanyouhui As Label
	Private lbltitle As Label
	Private lbltotalhours As Label
	Private kci As kcItem
	Private curyhq As yhq
	Private lbljiesuantot As Label
	Private pyhq As Panel
	Private dtot As Double
	Private pc As PayCls
End Sub

Sub Activity_Create(FirstTime As Boolean)
	'Do not forget to load the layout file created with the visual designer. For example:
	Activity.LoadLayout("laybuyfudaoban")
	comm.aio(Activity)
	initviews
End Sub
Sub initviews
	kci=g_store.get("curkc")
	lbltotalhours.Text=$"共${kci.hours}小时"$
	pc.Initialize(Activity)
	lblfudaobanname.Text=kci.kctitle
	lbladdress.Text=kci.addr
	lblcuxiaoquan.Text="请选择优惠券"
	comm.setFA(lbljiesuanyouhui,"fa-rmb","0(无优惠)")
	comm.setFA(lbljiesuantot,"fa-rmb",kci.price_xsdz)
End Sub

Sub Activity_Resume

End Sub

Sub Activity_Pause (UserClosed As Boolean)

End Sub


Sub btnleft_Click
	Activity.Finish
End Sub
'Sub JobDone(thj As HttpJob)
'	ProgressDialogHide
'	If thj.Success Then
'		Dim str As String=thj.GetString
'		Dim nr As netRes=ParseHelper.getStatusData(str)
'		comm.L(str)
'		If nr.nCode=200 Then
'			Select thj.JobName
'			Case "subord"
'				comm.TL("订单提交成功")	
'				Dim parser As JSONParser 
'				parser.Initialize(str) 
'				Dim root As Map = parser.NextObject 
'				Dim data As String = root.Get("data") 
'				Dim order_sn As String = root.Get("order_sn") 
'				Dim status As String = root.Get("status") 
'				Dim pi As payItem
'				pi.Initialize
'				pi.title=kci.kctitle
'				pi.money=dtot
'				pi.pid=order_sn
'				g_store.put("pid",pi)
'				StartActivity(actSelectPayMethod)
'				Activity.Finish
'			End Select
'			
'		Else
'			comm.TL("错误:"&nr.sData)
'		End If
'	Else
'		comm.TL("网络错误:"&thj.JobName&thj.ErrorMessage)
'	End If
'	thj.Release
'End Sub
Sub btngopay_Click
'	ToastMessageShow("支付",True)
'	Activity.Finish
	'要提交的参数
	calc
	Dim yhqid As String=""
	Dim kcid As String=kci.kcid
	Dim totmoney As String=dtot
	Dim keshi As String=kci.hours
	Dim kcmode As String="学生上门"
	Dim addr As String=kci.addr
	'检测优惠券是否满足使用条件
	If curyhq<>Null And curyhq.IsInitialized Then
		If curyhq.uselimit<dtot Then
			yhqid=curyhq.yhdid
		Else
			comm.TL("当前订单不满足优惠券使用条件")
			curyhq=Null
		End If	
	End If
	Dim pid As payItem
	pid.Initialize
	pid.title=kci.kctitle
	pid.money=totmoney
	pid.pid=""
	pc.SubmitOrder(kcid,totmoney,keshi,yhqid,kcmode,addr,pid)
	'SubmitOrder(kcid,totmoney,keshi,yhqid,kcmode,addr)
End Sub
'Private Sub SubmitOrder(kcid As String,totmoney As String,keshi As String,yhqid As String,kc_mode As String,addr As String)
'	comm.showProgress("正在提交订单请稍后")
'	Dim parms() As String
'	If yhqid.Length>0 Then
'		parms=Array As String("yhj_id",yhqid,"kc_mode",kc_mode,"id",kcid,"money",totmoney,"keshi",keshi,"addr",addr)
'	Else	
'		parms=Array As String("yhj_id","0","kc_mode",kc_mode,"id",kcid,"money",totmoney,"keshi",keshi,"addr",addr)
'	End If
'	ParseHelper.doPostReqArr(Me,"subord",comm.getApi(comm.apiIdx.SUBMITORDER),parms,"")
'	
'End Sub
Sub calc
	If curyhq<>Null And curyhq.IsInitialized Then comm.setFA(lbljiesuanyouhui,"fa-rmb",curyhq.money&"(减免)")
	Try
		dtot=kci.price_xsdz
	Catch
		dtot=0
	End Try
	If curyhq<>Null And curyhq.IsInitialized Then
		If curyhq.uselimit<=dtot Then
			'优惠券满足使用金额
			dtot=dtot-curyhq.money
		Else
			comm.L("不满足优惠券使用条件")
			curyhq=Null
		End If
	End If
	comm.setFA(lbljiesuantot,"fa-rmb",$"$1.2{dtot}"$)
	
End Sub
Sub yhqselected(yhq As yhq)
	Log(yhq)
	curyhq=yhq
	comm.setItemVal(pyhq,yhq.yhqname&" "&yhq.money)
	calc
End Sub
Sub pyhq_Click
	CallSubDelayed2(actYhqList,"selyhq",Me)
End Sub